home *** CD-ROM | disk | FTP | other *** search
- import com.siemens.mp.io.File;
- import java.io.IOException;
-
- public class CoctailDatabase {
- private static final String[][] resources = new String[][]{{"Cocktail Manager", "Quit", "Menu", "Score it", "Back", "Search", "Save", "By name", "By ingredients", "Name", "Ingredients", "Recipe", "Browse Cocktails", "Search", "Search Cocktail", "Random Cocktail", "Create New Cocktail", "User score", "New Cocktail", "Send via SMS", "enter phone number", "About", "Help", "Use navi keys and softkeys to select your actions."}, {"Cocktail Manager", "Beenden", "Menü", "Bewerte", "Zurück", "Suchen", "Abnehmen", "Nach Name", "Nach Zutaten", "Name", "Zutaten", "Rezept", "Cocktail Liste", "Suchen", "Cocktail Suche", "Zufalls Cocktail", "Cocktail erstellen", "Benutzer Bewertung", "Neuer Cocktail", "SMS senden", "Rufnummer eintragen", "Um", "Hilfe", "Benutzen Sie Navitasten und Tastenhinweis, um Ihre Tätigkeiten auszuwählen."}, {"Manager de cocktail", "Quitter", "Menu", "Noter", "Retour", "Recherche", "Sauvegarde", "Par nom", "pPar ingrédients", "Nom", "Ingrédients", "Recette", "Sélectionner cocktail", "Recherche", "Chercher cocktail", "Cocktail aléatoire", "Créer un nouveau cocktail", "Score de l'utilisateur", "Nouveau cocktail", "Envoyer par SMS", "Entrer le numéro de téléphone", "Au sujet de", "Aide", "Utiliser la touche de navigation et les touches d'écran pour sélectionner les actions."}, {"Cocktail Manager", "Esci", "Menu", "Assegna punteggio", "Indietro", "Indietro", "Salva", "Per nome", "Per ingredienti", "Nome", "Ingredienti", "Ricetta", "Sfoglia cocktails", "Ricerca", "Cerca cocktail", "Cocktail casuale", "Crea nuovo cocktail", "Punteggio", "Nuovo cocktail", "Invia tramite SMS", "inserire numero telefonico", "Info", "Aiuto", "Usa il tasto di controllo e i tasti softkey per selezionare le tue azioni."}, {"Coctail Manager", "Salir", "Menu", "Puntualo", "Atrás", "Buscar", "Salvar", "Por nombre", "Por ingredientes", "Nombre", "Ingredientes", "Receta", "Navegar Coctails", "Buscar", "Buscar Coctail", "Coctail al azar", "Crear Coctail", "Puntuación de usuario", "Nuevo Coctail", "Enviar via SMS", "Introducir numero de telefono", "Sobre", "Ayuda", "Usar teclas de control y teclas de display para seleccionar tus acciones."}};
- private static final byte[] CSB = new byte[]{60, 99, 111, 99, 107, 116, 97, 105, 108, 62};
- private static final byte[] CEB = new byte[]{60, 47, 99, 111, 99, 107, 116, 97, 105, 108, 62};
- private static final byte[] NSB = new byte[]{60, 110, 97, 109, 101, 62};
- private static final byte[] NEB = new byte[]{60, 47, 110, 97, 109, 101, 62};
- private static final byte[] ISB = new byte[]{60, 105, 110, 103, 114, 101, 100, 105, 101, 110, 116, 115, 62};
- private static final byte[] IEB = new byte[]{60, 47, 105, 110, 103, 114, 101, 100, 105, 101, 110, 116, 115, 62};
- private static final byte[] RSB = new byte[]{60, 114, 101, 99, 105, 112, 101, 62};
- private static final byte[] REB = new byte[]{60, 47, 114, 101, 99, 105, 112, 101, 62};
- private static final byte[] SSB = new byte[]{60, 115, 99, 111, 114, 101, 62};
- private static final byte[] SEB = new byte[]{60, 47, 115, 99, 111, 114, 101, 62};
- // $FF: renamed from: CS byte[]
- private static final byte[] field_0 = new byte[]{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- // $FF: renamed from: CE byte[]
- private static final byte[] field_1 = new byte[]{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- // $FF: renamed from: NS byte[]
- private static final byte[] field_2 = new byte[]{-1, 0, 0, 0, 0, 0, 0};
- // $FF: renamed from: NE byte[]
- private static final byte[] field_3 = new byte[]{-1, 0, 0, 0, 0, 0, 0, 0};
- // $FF: renamed from: IS byte[]
- private static final byte[] field_4 = new byte[]{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- // $FF: renamed from: IE byte[]
- private static final byte[] field_5 = new byte[]{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- // $FF: renamed from: RS byte[]
- private static final byte[] field_6 = new byte[]{-1, 0, 0, 0, 0, 0, 0, 0, 0};
- // $FF: renamed from: RE byte[]
- private static final byte[] field_7 = new byte[]{-1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
- // $FF: renamed from: SS byte[]
- private static final byte[] field_8 = new byte[]{-1, 0, 0, 0, 0, 0, 0, 0};
- // $FF: renamed from: SE byte[]
- private static final byte[] field_9 = new byte[]{-1, 0, 0, 0, 0, 0, 0, 0, 0};
-
- public static String getString(int i) {
- return resources[Locale.getCurrentLocale()][i];
- }
-
- public static void loadCoctails(CoctailBar bar) {
- byte[] coctails = readFromFile("cocktails." + Locale.getLocaleCode());
- int pos = 0;
-
- int index;
- while((index = indexOf(coctails, CEB, field_1, pos)) >= 0 && index < coctails.length) {
- index += 10;
- byte[] coctail = substring(coctails, pos, index);
- pos = index + 1;
- bar.addCoctail(parseCoctailData(coctail));
- }
-
- coctails = readFromFile("usercocktails");
- pos = 0;
-
- while((index = indexOf(coctails, CEB, field_1, pos)) >= 0 && index < coctails.length) {
- index += 10;
- byte[] var14 = substring(coctails, pos, index);
- pos = index + 1;
- bar.addCoctail(parseCoctailData(var14));
- }
-
- coctails = readFromFile("userscore");
- pos = 0;
-
- while((index = indexOf(coctails, CEB, field_1, pos)) >= 0 && index < coctails.length) {
- index += 10;
- byte[] var15 = substring(coctails, pos, index);
- pos = index + 1;
- parseScoreData(var15, bar);
- }
-
- }
-
- private static Coctail parseCoctailData(byte[] coctail) {
- String name = new String(substring(coctail, indexOf(coctail, NSB, field_2) + 6, indexOf(coctail, NEB, field_3) - 1));
- String ingredients = (new String(substring(coctail, indexOf(coctail, ISB, field_4) + 13, indexOf(coctail, IEB, field_5) - 1))).trim();
- String recipe = (new String(substring(coctail, indexOf(coctail, RSB, field_6) + 8, indexOf(coctail, REB, field_7) - 1))).trim();
- return new Coctail(name, ingredients, recipe);
- }
-
- private static void parseScoreData(byte[] coctail, CoctailBar bar) {
- String name = new String(substring(coctail, indexOf(coctail, NSB, field_2) + 6, indexOf(coctail, NEB, field_3) - 1));
- int score = Integer.parseInt(new String(substring(coctail, indexOf(coctail, SSB, field_8) + 7, indexOf(coctail, SEB, field_9) - 1)));
- bar.setScore(name, score);
- }
-
- private static byte[] readFromFile(String filename) {
- byte[] data = null;
-
- try {
- File file = new File();
- int fileHandle = file.open(filename);
- int len = file.length(fileHandle);
- data = new byte[len];
- file.seek(fileHandle, 0);
- file.read(fileHandle, data, 0, len);
- } catch (IOException var5) {
- }
-
- return data;
- }
-
- public static void storeScore(Coctail coctail) {
- storeToFile("userscore", coctail.createScoreXML());
- }
-
- public static void storeCoctail(Coctail coctail) {
- storeToFile("usercocktails", coctail.createCoctailXML());
- }
-
- private static void storeToFile(String filename, String buffer) {
- try {
- File file = new File();
- int fileHandle = file.open(filename);
- byte[] data = buffer.getBytes();
- file.seek(fileHandle, file.length(fileHandle));
- file.write(fileHandle, data, 0, data.length);
- } catch (IOException var5) {
- }
-
- }
-
- private static int indexOf(byte[] a, byte[] p, byte[] next) {
- return indexOf(a, p, next, 0);
- }
-
- private static int indexOf(byte[] a, byte[] p, byte[] next, int pos) {
- int M = p.length;
- int N = a.length;
- int i = pos;
-
- int j;
- for(j = 0; j < M && i < N; ++j) {
- while(j >= 0 && a[i] != p[j]) {
- j = next[j];
- }
-
- ++i;
- }
-
- return j == M ? i - M : i;
- }
-
- private static byte[] substring(byte[] a, int startIndex, int endIndex) {
- byte[] data = new byte[endIndex - startIndex + 1];
-
- for(int i = 0; i < data.length; ++i) {
- data[i] = a[startIndex + i];
- }
-
- return data;
- }
- }
-